import Vue from 'vue'
import Router from 'vue-router'

// in development-env not use lazy-loading, because lazy-loading too many pages will cause webpack hot update too slow. so only in production use lazy-loading;
// detail: https://panjiachen.github.io/vue-element-admin-site/#/lazy-loading

Vue.use(Router)

/* Layout */
import Layout from '../views/layout/Layout'

/**
* hidden: true                   if `hidden:true` will not show in the sidebar(default is false)
* alwaysShow: true               if set true, will always show the root menu, whatever its child routes length
*                                if not set alwaysShow, only more than one route under the children
*                                it will becomes nested mode, otherwise not show the root menu
* redirect: noredirect           if `redirect:noredirect` will no redirect in the breadcrumb
* name:'router-name'             the name is used by <keep-alive> (must set!!!)
* meta : {
    title: 'title'               the name show in subMenu and breadcrumb (recommend set)
    icon: 'svg-name'             the icon show in the sidebar
    breadcrumb: false            if false, the item will hidden in breadcrumb(default is true)
  }
**/
export const constantRouterMap = [
  { path: '/login', component: () => import('@/views/login/index'), hidden: true },
  { path: '/404', component: () => import('@/views/404'), hidden: true },

  {
    path: '/',
    component: Layout,
    redirect: '/sale',
    name: 'Dashboard',
    hidden: true,
    children: [{
      path: 'dashboard',
      component: () => import('@/views/dashboard/index')
    }]
  },

	{
	path: '/sale',
	component: Layout,
	redirect: '/sale/saleOut',
    name: 'sale',
    meta: { title: '零售管理', icon: 'form' },
		children: [{
        path: 'saleOut',
        name: 'saleOut',
        component: () => import('@/views/retail/erp_retail'),
        meta: { title: '零售出库', icon: 'form' }
		},
      {
        path: 'saleReturn',
        name: 'saleReturn',
        component: () => import('@/views/retail/erp_retail_return'),
        meta: { title: '零售退货', icon: 'form' }
      }
		]
  },
  {
    path: '/retail',
    component: Layout,
    name: 'retail',
    meta: { title: '销售管理', icon: 'form' },
    children: [
      {
        path: 'retailOrder',
        name: 'retailOrder',
        component: () => import('@/views/erp_sale/sale_order'),
        meta: { title: '销售订单', icon: 'form' }
      },
      {
        path: 'retailOut',
        name: 'retailOut',
        component: () => import('@/views/erp_sale/sale_out'),
        meta: { title: '销售出库', icon: 'form' }
      },
      {
        path: 'retailReturn',
        name: 'retailReturn',
        component: () => import('@/views/erp_sale/sale_return'),
        meta: { title: '销售退货', icon: 'form' }
      }
    ]
  },
	
  {
    path: '/process',
    component: Layout,
    redirect: '/process/process',
    name: 'process',
    meta: { title: '加工拆分', icon: 'example' },
    children: [
      {
        path: 'processCompound',
        name: 'processCompound',
        component: () => import('@/views/process/processCompound'),
        meta: { title: '加工表', icon: 'table' }
      },
      {
        path: 'processCompound1',
        name: 'processCompound1',
        component: () => import('@/views/process/processCompound1'),
        meta: { title: '拆分表', icon: 'table' }
      },
      {
        path: 'processBom',
        name: 'processBom',
        component: () => import('@/views/process/processBom'),
        meta: { title: '加工/拆分物表', icon: 'table' }
      },
    ]
  },

  {
    path: '/finance',
    component: Layout,
	redirect: '/finance/input',
	name: 'finance',
	meta: { title: '财务管理', icon: 'example' },
    children: [
      {
        path: 'input',
        name: 'Input',
		component: () => import('@/views/finance/input'),
        meta: { title: '收款单', icon: 'form' },
		
      },
	  {
	    path: 'output',
	    name: 'Output',
	  		component: () => import('@/views/finance/output'),
	    meta: { title: '付款单', icon: 'form' },
	  		
	  }
    ]
  },

	{
	  path: '/product',
	  component: Layout,
	  redirect: '/product/product',
	  name: 'product',
	  meta: { title: '商品管理', icon: 'example' },
	  children: [
	    {
	      path: 'product',
	      name: 'product',
	      component: () => import('@/views/product/product'),
	      meta: { title: '商品信息', icon: 'table' }
	    },
	    {
	      path: 'productUnit',
	      name: 'productUnit',
	      component: () => import('@/views/product/productUnit'),
	      meta: { title: '商品单位', icon: 'table' }
	    }/* ,
	    {
	      path: 'productClass',
	      name: 'productClass',
	      component: () => import('@/views/product/productClass'),
	      meta: { title: '商品类别', icon: 'tree' }
	    } */
	  ]
	},
	{
	  path: '/base',
	  component: Layout,
	  redirect: '/base/supplier',
	  name: 'Base',
	  meta: { title: '基本信息', icon: 'example' },
	  children: [
	    {
	      path: 'supplier',
	      name: 'Supplier',
	      component: () => import('@/views/base/supplier'),
	      meta: { title: '供应商信息', icon: 'table' }
	    },
	    {
	      path: 'consumer',
	      name: 'Consumer',
	      component: () => import('@/views/base/consumer'),
	      meta: { title: '客户信息', icon: 'consumer' }
	    },
			{
	      path: 'account',
	      name: 'Account',
	      component: () => import('@/views/base/account'),
	      meta: { title: '账户信息', icon: 'consumer' }
	    }
			
	  ]
	},

/*  {
    path: '/nested',
    component: Layout,
    redirect: '/nested/menu1',
    name: 'Nested',
    meta: {
      title: 'Nested',
      icon: 'nested'
    },
    children: [
      {
        path: 'menu1',
        component: () => import('@/views/nested/menu1/index'), // Parent router-view
        name: 'Menu1',
        meta: { title: 'Menu1' },
        children: [
          {
            path: 'menu1-1',
            component: () => import('@/views/nested/menu1/menu1-1'),
            name: 'Menu1-1',
            meta: { title: 'Menu1-1' }
          },
          {
            path: 'menu1-2',
            component: () => import('@/views/nested/menu1/menu1-2'),
            name: 'Menu1-2',
            meta: { title: 'Menu1-2' },
            children: [
              {
                path: 'menu1-2-1',
                component: () => import('@/views/nested/menu1/menu1-2/menu1-2-1'),
                name: 'Menu1-2-1',
                meta: { title: 'Menu1-2-1' }
              },
              {
                path: 'menu1-2-2',
                component: () => import('@/views/nested/menu1/menu1-2/menu1-2-2'),
                name: 'Menu1-2-2',
                meta: { title: 'Menu1-2-2' }
              }
            ]
          },
          {
            path: 'menu1-3',
            component: () => import('@/views/nested/menu1/menu1-3'),
            name: 'Menu1-3',
            meta: { title: 'Menu1-3' }
          }
        ]
      },
      {
        path: 'menu2',
        component: () => import('@/views/nested/menu2/index'),
        meta: { title: 'menu2' }
      }
    ]
  },

  {
    path: 'external-link',
    component: Layout,
    children: [
      {
        path: 'https://panjiachen.github.io/vue-element-admin-site/#/',
        meta: { title: 'External Link', icon: 'link' }
      }
    ]
  }, */

  { path: '*', redirect: '/404', hidden: true }
]

export default new Router({
  // mode: 'history', //后端支持可开
  scrollBehavior: () => ({ y: 0 }),
  routes: constantRouterMap
})
